﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace peonwar
{
    class Cursor : Sprite
    {
        public int taille;
        public string type;
        public Color couleur;
        public Color couleur_touche;
        public Color couleur_current;

        public Cursor()
        {
            this.type = "O";
            this.couleur = new Color(0, 255, 0);
            this.taille = 1;
            this.couleur_touche = Color.Red;
        }

        public void UpdateCursorInfos()
        {
            this.type = SettingManager.CurrentProfil.TypeCursor;
            this.taille = SettingManager.CurrentProfil.TailleCursor;
            this.couleur = SettingManager.CurrentProfil.Color1Cursor;
            this.couleur_touche = SettingManager.CurrentProfil.Color2Cursor;
        }

        public void UpDate(MouseState mouse)
        {
            
            if (type != ".")
            {
                if (taille == 1)
                    Position = new Vector2(mouse.X - 7, mouse.Y - 11);
                if (taille == 2)
                    Position = new Vector2(mouse.X - 12, mouse.Y - 19);
                if (taille == 3)
                    Position = new Vector2(mouse.X - 17, mouse.Y - 25);
            }
            else
            {

                if (taille == 1)
                    Position = new Vector2(mouse.X - 3, mouse.Y - 15);
                if (taille == 2)
                    Position = new Vector2(mouse.X - 6, mouse.Y - 26);
                if (taille == 3)
                    Position = new Vector2(mouse.X - 8, mouse.Y - 36);
            }

            if (mouse.LeftButton == ButtonState.Pressed || mouse.RightButton == ButtonState.Pressed)
                couleur_current = couleur_touche;

            if (mouse.LeftButton == ButtonState.Released && mouse.RightButton == ButtonState.Released)
                couleur_current = couleur;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (taille ==1)
                spriteBatch.DrawString(GameData.Font_Cursor_Little, type, Position, couleur_current);
            if (taille == 2)
                spriteBatch.DrawString(GameData.Font_Cursor_Medium, type, Position, couleur_current);
            if (taille == 3)
                spriteBatch.DrawString(GameData.Font_Cursor_Big, type, Position, couleur_current);
        }
    }
}
